package com.cpm.offcn.pubsub;

import com.cpm.offcn.utils.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitUtils.getConnection();
        Channel channel = connection.createChannel();
        String str = new Scanner(System.in).next();
        //绑定交换机
        //第一个为交换机名
        //第二个为队列名（队列在消费者端创建）
        channel.basicPublish("EXCHANGE_WEATHER","",null,str.getBytes());
        channel.close();
        connection.close();
        System.out.println("发送成功");
    }
}
